package org.example.ruoxing_admin_springboot3.config;
import org.example.ruoxing_admin_springboot3.Interceptor.WebApiInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * @description 拦截器的配置类
 * @author 莫若省
 * @createTime 2024/4/29
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Bean
    public HandlerInterceptor getWebApiInterceptor(){
        return new WebApiInterceptor();
    }
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getWebApiInterceptor())
                //需要拦截的路径
                .addPathPatterns("/**")
                //排除拦截的路径
                .excludePathPatterns("/no_auth/**");
    }

}
